<template>
	<view>
		<button @click="onsettimecall()">单次计时器settimeout</button>
		<button @click="onsettimecallxy(username,password)">带参数</button>
		<button @click="ontimeoutclear()">取消定时器</button>
		<button @click="oninteral()">周期打印计时器</button>
		<button @click="oninteralid()">取消周期打印计时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username:'zyq',
				password:'666',
				timeoutid:null,
				count:0,
			}
		},
		methods: {
			onsettimecall(){
				console.log("onsettimecall-->");
				//setTimeout(callback,ms,any[])
				this.timeoutid = setTimeout(()=>{
					console.log("我延时2s才会打印")
				},2000)
			},
			onsettimecallxy(name,pwd){
				console.log("onsettimecallxy-->name:"+name+",pwd"+pwd);
				
			},
			ontimeoutclear(){
				console.log("ontimeoutclear------>定时器被我取消了"+this.timeoutid);
				clearTimeout(this.timeoutid)
			},
			oninteral(){
				this.timeoutid =setInterval(()=>{
					this.count++;
					console.log("周期打印 count",this.count);
				},1000)
			},
			onclearinter(){
				console.log("onclearinter:",this.oninteralid);
				clearInterval(this.interalid)
			}
		}
	}
</script>

<style>

</style>
